using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace TestMonkey.Core.Templates
{
    public class SimpleMemoryLeak : ConstructorTemplateProcessor
    {
        public override bool ShouldRun(Type type)
        {
            return type.IsClass && type.HasConstructors();
        }

        public override bool ShouldRun(Type type, ConstructorInfo constructor)
        {
            return constructor.IsCreatable();
        }

        public override string TemplateFileName(Type type)
        {
            if (type.IsCreatable())
                return "Default";
            else
                return "SimpleMemoryLeak"; //we only use this template when we need the helper to create the object

        }

        protected override void OnProcessPartialTemplate(Type type, ConstructorInfo constructor, int constructorIndex, StringBuilder template)
        {
            base.OnProcessPartialTemplate(type, constructor, constructorIndex, template);
            template.Replace("$Class-Constructor$", constructor.GetConstructorCode());
        }

    }
}
